<template>
  <div>
    <template v-if="newcon.goods">
<van-swipe @change="onChange">
      <van-swipe-item><img :src="newcon.goods.pic"/></van-swipe-item>
      <van-swipe-item><img :src="newcon.goods.pic1"/></van-swipe-item>
      <van-swipe-item><img :src="newcon.goods.pic2"/></van-swipe-item>
      <van-swipe-item><img :src="newcon.goods.pic3"/></van-swipe-item>
      <van-swipe-item><img :src="newcon.goods.pic4"/></van-swipe-item>
      <template #indicator>
        <div class="custom-indicator">{{ current + 1 }}/5</div>
        <span class="icon-jiantou iconfont" @click="fun()"></span>
        <img src="../../../public/img/24.webp" />
      </template>
    </van-swipe>
    </template>
    
    <Pr></Pr>
    <Ga></Ga>
  </div>
</template>

<script>
import Pr from "../../components/xQ/price.vue";
import Ga from "../../components/xQ/goodsAction.vue";
import { getData } from "../../api/getapi";
import { getlink } from "../../api/getapi";
export default {
  components: { Pr, Ga },
  data() {
    return {
      newcon: [],
      arr:[],
      newarr:[],
      newarr1:[],
      current: 0,
    };
  },
  methods: {
    onChange(index) {
      this.current = index;
    },
    fun() {
      this.$router.go(-1);
    },
  },
  mounted() {
    // console.log(this.$route.query.arr);

    getData("/api/shop/findMjGoods",{sid:this.$route.query.dataList}).then((ok) => {
      this.arr=ok.data;
      // this.arr=this.arr[0].goods;
      this.newcon = this.arr.find(v => 
        v.shop.sid == this.$route.query.dataList
      );
      // console.log(this.newcon)
    });
    // console.log(this.$route.query.dataList);
    getlink("/api/findAllById?level1=1").then((ok)=>{
      // console.log(ok);
      this.newarr=ok.data;
      this.newarr1 = this.newarr.filter((v) =>{
       if(v.sid == this.$route.query.dataList){
         return v
       }
      //  console.log(v);
      });
     
    })
  },
};
</script>

<style scoped>
@import url("http://at.alicdn.com/t/font_2803014_0zvducx9h22.css");
.custom-indicator {
  position: absolute;
  right: 20px;
  bottom: 50px;
  padding: 2px 5px;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 20%;
}
img {
  width: 100%;
  height: 100%;
}
span {
  position: absolute;
  top: 0.4rem;
  font-size: 0.8rem;
  left: 0.6rem;
  color: grey;
}
</style>
